# Author: williamjcm <w.jcm59@gmail.com>
# Contributor: mosra <mosra@centrum.cz>
# Based on the packages/archlinux/PKGBUILD file by mosra <mosra@centrum.cz> and the MSYS2/MinGW PKGBUILD templates

_realname=magnum
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=dev
pkgrel=1
pkgdesc="C++11/C++14 graphics middleware for games and data visualization"
arch=('any')
url="https://magnum.graphics/"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-corrade"
         "${MINGW_PACKAGE_PREFIX}-openal"
         "${MINGW_PACKAGE_PREFIX}-SDL2"
         "${MINGW_PACKAGE_PREFIX}-glfw"
         "${MINGW_PACKAGE_PREFIX}-vulkan-loader")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-ninja")
options=('!strip')

_rootdir=$startdir/../../

build() {
    mkdir -p "$_rootdir/build-${CARCH}"
    cd "$_rootdir/build-${CARCH}"

    MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
        ${MINGW_PREFIX}/bin/cmake .. \
            -G'Ninja' \
            -DCMAKE_BUILD_TYPE=Debug \
            -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
            -DMAGNUM_WITH_AUDIO=ON \
            -DMAGNUM_WITH_VK=ON \
            -DMAGNUM_WITH_GLFWAPPLICATION=ON \
            -DMAGNUM_WITH_SDL2APPLICATION=ON \
            -DMAGNUM_WITH_WINDOWLESSWGLAPPLICATION=ON \
            -DMAGNUM_WITH_WGLCONTEXT=ON \
            -DMAGNUM_WITH_OPENGLTESTER=ON \
            -DMAGNUM_WITH_ANYAUDIOIMPORTER=ON \
            -DMAGNUM_WITH_ANYIMAGECONVERTER=ON \
            -DMAGNUM_WITH_ANYIMAGEIMPORTER=ON \
            -DMAGNUM_WITH_ANYSCENECONVERTER=ON \
            -DMAGNUM_WITH_ANYSCENEIMPORTER=ON \
            -DMAGNUM_WITH_ANYSHADERCONVERTER=ON \
            -DMAGNUM_WITH_MAGNUMFONT=ON \
            -DMAGNUM_WITH_MAGNUMFONTCONVERTER=ON \
            -DMAGNUM_WITH_OBJIMPORTER=ON \
            -DMAGNUM_WITH_TGAIMAGECONVERTER=ON \
            -DMAGNUM_WITH_TGAIMPORTER=ON \
            -DMAGNUM_WITH_WAVAUDIOIMPORTER=ON \
            -DMAGNUM_WITH_DISTANCEFIELDCONVERTER=ON \
            -DMAGNUM_WITH_FONTCONVERTER=ON \
            -DMAGNUM_WITH_IMAGECONVERTER=ON \
            -DMAGNUM_WITH_SCENECONVERTER=ON \
            -DMAGNUM_WITH_SHADERCONVERTER=ON \
            -DMAGNUM_WITH_GL_INFO=ON \
            -DMAGNUM_WITH_VK_INFO=ON \
            -DMAGNUM_WITH_AL_INFO=ON
    ninja
}

package() {
    cd "$_rootdir/build-${CARCH}"
    DESTDIR="${pkgdir}" ninja install
}
